<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        // Objcet.assign(); // 合并对象
        let json = {
            a: 1
        };
        let json2 = {
            b: 2,
            a: 5
        };
        let json3 = {
            c: 3
        };
        console.log(Object.assign(json, json2, json3)); // 后面的a覆盖前面a

        // ----------------------------------------------

        let obj1 = {
            a: 1,
            token: 'aaa123'
        }
        let obj2 = {
            b: 2
        }
        let option = {
            c: 3,
            token: 'xxxx123'
        };

        // 在 axios 请求的时候 把token 合并到请求里面去可以用
        let newobj = Object.assign({}, obj1, obj2, option); // {a: 1, token: "xxxx123", b: 2, c: 3}
        console.log(newobj);
    </script>
</body>

</html>